package com.eric.shardingsphere.sharding.service;

import com.eric.shardingsphere.sharding.entity.Order;
import com.eric.shardingsphere.sharding.mapper.OrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author chenw-i
 * @version 1.0.0
 * @ClassName OrderService.java
 * @Description TODO
 * @createTime 2020年07月22日 12:19:00
 */
@Service
@Slf4j
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public void test(){
        Order order = orderMapper.selectById(1l);
        log.info("select by 11 result={}" ,order);
        order = new Order();
        order.setUserId(100l);
        orderMapper.insert(order);
        log.info("insert {}",order);

        order = orderMapper.selectByIdAndTenantId(order.getId(),order.getTenantId());
        log.info("select by 22 result={}",order);
    }
}
